//
// Created by 24319 on 2025/5/25.
//
#include <stdbool.h>

#ifndef WIFIDATA_UARTSENDDATA_H
#define WIFIDATA_UARTSENDDATA_H
void sendbyte(uint8_t byte);
void sendarray(uint8_t *array,uint16_t Length);
void sendstring(char *String);
void USART1_IRQHandler(void);
// 定义返回状态
typedef enum {
    REV_WAIT = 0,   // 等待接收
    REV_OK = 1      // 接收完成
} RevStatus;


// WiFi配置参数（需根据实际修改）
#define ESP8266_SSID       "aaaaa"
#define ESP8266_PASSWORD   "88888888"
#define ESP8266_MQTT_INFO		"AT+MQTTCONN=0,\"mqtts.heclouds.com\",1883,1\r\n"
#define ESP8266_ONENET_INFO "AT+MQTTUSERCFG=0,1,\"d1\",\"3h7XtWS80P\",\"version=2018-10-31&res=products%2F3h7XtWS80P%2Fdevices%2Fd1&et=1779725613&method=md5&sign=zmN4kX%2BhS1n1zAGGfRcOiw%3D%3D\",0,0,\"\"\r\n"
#define ESP8266_MQTT_PUBLISH "AT+MQTTPUB=0,\"$sys/3h7XtWS80P/d1/thing/property/post\",\"{\\\"id\\\":\\\"123\\\"\\,\\\"params\\\":{\\\"temp\\\":{\\\"value\\\":10.4\\}\\,\\\"LEDState\\\":{\\\"value\\\":true}}}\",0,0\r\n"
#define ESP8266_MQTT_SUBSCRIBE "AT+MQTTSUB=0,\"$sys/3h7XtWS80P/d1/thing/property/set\",0\r\n"

#define ESP8266_BUF_SIZE  1
extern unsigned char esp8266_buf[1];
extern unsigned short esp8266_cnt;

// 函数声明
void ESP8266_Init(void);
void ESP8266_SendCmd(char *cmd);
uint8_t Serial_GetRxFlag(void);
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size);
uint8_t CheckForOK(uint8_t *buffer, uint16_t length);
char* generateMqttPublishCommand(float temp, bool ledState);


#endif //WIFIDATA_UARTSENDDATA_H
